package com.bridgeintelligent.tag.webserver.dim.mgmt.service.report;

import com.bridgeintelligent.tag.mapper.BannerMapper;
import com.bridgeintelligent.tag.utils.DateHelper;
import com.bridgeintelligent.tag.webserver.dim.mgmt.api.IdWorker;
import com.bridgeintelligent.tag.webserver.dim.mgmt.api.report.BannerInfo;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@AllArgsConstructor
@Slf4j
public class BannerServiceImpl implements BannerService {

    private BannerMapper bannerMapper;


    @Override
    public void addBanner(BannerInfo info) {
        info.setId(IdWorker.nextId());
        info.setIsDel("0");
        info.setDateTime(DateHelper.currentDateTime());
        bannerMapper.addBanner(info);
    }

    @Override
    public void updateBanner(BannerInfo info) {
        bannerMapper.updateBanner(info);
    }

    @Override
    public List<BannerInfo> listBanner() {
        return bannerMapper.listBanner();
    }

    @Override
    public BannerInfo findOne(String id) {
        return bannerMapper.findOne(id);
    }

    @Override
    public void deleteOne(String id) {
        BannerInfo info = new BannerInfo().setId(id).setIsDel("1");
        bannerMapper.updateBanner(info);
    }
}
